#include <iostream>

using namespace std;
class Animal
{
public:
	virtual void eat()  //虚函数
	{
		cout<<"动物吃"<<endl;
	}
	virtual void animalSleep()  //虚函数
	{
		cout<<"动物睡觉"<<endl;
	}
	void animalRun()  //非虚函数
	{
		cout<<"动物跑"<<endl;
	}
private:
	int age;
};

class Dog:public Animal
{
public:
	virtual void eat()  //重写了父类其中一个虚函数，另一个没有重写
	{
		cout<<"狗吃骨头"<<endl;
	} 
};

class Tugou:public Dog
{
public:
	virtual void eat()
	{
		cout<<"土狗吃火腿肠"<<endl;
	}	
}; 




//C++允许 
void animalEat(Animal &animal) //希望具有通用性
{
	animal.eat();
}
int main()
{
	Dog dog;
	
 	Animal *p=&dog;
	p->eat();
	p->animalSleep(); 
	cout<<sizeof(Animal)<<endl;
	cout<<sizeof(dog)<<endl;
	
}
